<ion-view view-title="分类 - {{catalog.name}}" show-tabs>
    <ion-nav-buttons side="right">
        <button class="button button-icon ion-ios-trash-outline margin-right" ng-click="delete()"></button>
        <button class="button" ng-class="{'button-icon ion-ios-compose-outline':!$root.isEdit,'button-clear':$root.isEdit}" ng-click="$root.toggleEdit();"><span ng-if="$root.isEdit">取消</span></button>
    </ion-nav-buttons>

    <ion-content>
        <form name="catalogForm" ng-submit="$root.toggleEdit();update();">

            <ion-list class="editable-list" can-swipe="listCanSwipe">
                <ion-item class="item-input item-icon-left">
                    <i class="icon ion-ios-folder-outline royal"></i>
                    <span class="list-label">分类名称</span>
                    <input type="text" name="name" maxlength="20" ng-model="catalog.name" ng-readonly="!$root.isEdit" auto-focus />
                </ion-item>

                <ion-item class="item-select item-icon-left">
                    <i class="icon ion-android-funnel royal"></i>
                    <span class="list-label">上级分类</span>
                    <select name="state" ng-model="catalog.parent_id" ng-if="$root.isEdit">
                        <option value="{{catalog.parent_id}}" disabled>{{parentName}}</option>
                        <option value="" disabled>————</option>
                        <option ng-repeat="item in catalogs" value="{{item._id}}">{{item.name}}</option>
                    </select>
                    <span ng-if="!$root.isEdit">{{parentName}}</span>
                </ion-item>

                <ion-item class="item-divider margin-top-large">{{catalog.name}}商品可用属性</ion-item>

                <ion-item class="item-icon-right" ng-repeat="property in catalog.properties" ng-class="{'margin-bottom-large':$last}" ng-click="openModal(property)">
                    {{property.name}}
                    <span class="item-note">{{property.value_set.length}}</span>
                    <i class="icon ion-ios-arrow-right" ng-if="property.field_type!='input'"></i>
                </ion-item>

            </ion-list>
            <button class="button button-block button-balanced" type="submit" ng-if="$root.isEdit">保存</button>

        </form>

    </ion-content>
</ion-view>
